package com.bkgy.controller.acidefficiency.controller;

import com.bkgy.controller.acidefficiency.entity.*;
import com.bkgy.controller.acidefficiency.service.AcidEfficiencyService;
import com.bkgy.controller.repOutput.service.IRepOutputService;
import com.bkgy.controller.tbbxrecord.service.ITbBxSyncService;
import com.bkgy.sys.common.entity.ResultData;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * 2280酸轧效率分析
 */
@Tag(name = "2280酸轧效率分析", description = "2280酸轧效率分析")
@RestController
@RequestMapping("/acideff")
public class AcidEfficiencyController {

    @Autowired
    private AcidEfficiencyService service;
    @Autowired
    private ITbBxSyncService syncService;
    @Autowired
    private IRepOutputService repOutputService;

    @Operation(summary = "酸轧产量记录", description = "酸轧产量记录")
    @GetMapping("/tcmOutputRecord")
    public ResultData tcmOutputRecord() {
        return repOutputService.tcmOutputRecord();
    }

    @Operation(summary = "根据条件查询2280酸轧效率分析七个时间", description = "根据条件查询2280酸轧效率分析七个时间")
    @PostMapping("/getAcidEfficiency")
    public ResultData getAcidEfficiency(@RequestBody @Valid AcidEfficiency request) {
        return service.getAcidEfficiency(request);
    }

    @Operation(summary = "生产时序统计", description = "生产时序统计")
    @PostMapping("/getAcidEfficiencyList")
    public ResultData getAcidEfficiencyList(@RequestBody @Valid AcidEfficiencyListReq request) {
        return service.getAcidEfficiencyList(request);
    }

    @Operation(summary = "生产时序统计", description = "生产时序统计")
    @PostMapping("/getAcidEfficiencyLists")
    public ResultData getAcidEfficiencyLists(@RequestBody @Valid AcidEfficiencyListReq request) {
        return service.getAcidEfficiencyLists(request);
    }

    @Operation(summary = "重焊次数追溯", description = "重焊次数追溯")
    @PostMapping("/getReWeldList")
    public ResultData getReWeldList(@RequestBody @Valid ReWeldListReq request) {
        return service.getReWeldList(request);
    }

    @Operation(summary = "单卷生产效率分析原因保存", description = "单卷生产效率分析原因保存")
    @PostMapping("/saveSingleRoll")
    public ResultData saveSingleRoll(@RequestBody @Valid SingleRollSaveReq req) {
        return syncService.saveSingleRoll(req);
    }

    @Operation(summary = "单卷生产效率分析评价", description = "单卷生产效率分析评价")
    @PostMapping("/getSingleRollList")
    public ResultData selectPage(@RequestBody @Valid SingleRollListReq request) {
        return syncService.selectPage(request);
    }

    @Operation(summary = "单卷计划秒用时", description = "单卷计划秒用时")
    @GetMapping("/getSingleRollSec")
    public ResultData getSingleRollSec(String entId) {
        if(StringUtils.isEmpty(entId)){
            return ResultData.ResultDataSuccessSelf("入口卷号不能为空",null);
        }
        return syncService.getSingleRollSec(entId);
    }

    @Operation(summary = "单卷生产效率分析导出", description = "单卷生产效率分析导出")
    @PostMapping("/exportXlsx")
    public void exportXlsx(@RequestBody SingleRollReq singleRollReq, HttpServletResponse response) {
        syncService.aosrpeExcel(singleRollReq, response);
    }

    @Operation(summary = "生产时序导出", description = "生产时序导出")
    @PostMapping("/exportProductionscheduleXlsx")
    public void exportProductionscheduleXlsx(@RequestBody AcidEfficiencyListReq req, HttpServletResponse response) {
        service.productionscheduleExcel(req, response);
    }

    @Operation(summary = "获取预警内容", description = "获取预警内容")
    @PostMapping("/getEarlyWarning")
    public ResultData getEarlyWarning() {
        return service.getEarlyWarning();
    }

    @Operation(summary = "获取标准时间", description = "获取标准时间")
    @PostMapping("/getDiffTime")
    public ResultData getDiffTime() {
        return service.getDiffTime();
    }

    @Operation(summary = "获取换辊明细", description = "获取换辊明细")
    @PostMapping("/getRollChange")
    public ResultData getRollChange(@RequestBody @Valid ChangeRollListReq changeRollListReq) {
        return service.getRollChange(changeRollListReq);
    }

    @Operation(summary = "获取开卷机异常明细", description = "获取开卷机异常明细")
    @PostMapping("/getUncoiler")
    public ResultData getUncoiler() {
        return service.getUncoiler();
    }

}
